/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'delFlag',
        type: 'int',
        hideQuery:true,
        'export':false,
        hideQueryType:'eq',
        hideQueryValue:1,
        hide:true

    },
    {
        id: 'id',
        title: '编号',
        type: 'number',
        headerClass: 'text-center width-50',
        columnClass: 'text-center width-50',
        fastSort: true,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'u.userName',
        title: '用户名',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-left',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'u.mobile',
        title: '手机号',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'type',
        title: '类型',
        type: 'int',
        headerClass: 'text-center',
        columnClass: 'text-left ',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable: {
            1: $lang.accountLogType.T1,
            2: $lang.accountLogType.T2,
            3: $lang.accountLogType.T3,
            4: $lang.accountLogType.T4,
            8: $lang.accountLogType.T8,
            9: $lang.accountLogType.T9,
            10: $lang.accountLogType.T10,
            11: $lang.accountLogType.T11,
            12: $lang.accountLogType.T12,
            13: $lang.accountLogType.T13,
            15: $lang.accountLogType.T15,
            16: $lang.accountLogType.T16,
            17: $lang.accountLogType.T17,
            18: $lang.accountLogType.T18,
            19: $lang.accountLogType.T19,
            20: $lang.accountLogType.T20,
            21: $lang.accountLogType.T21,
            22: $lang.accountLogType.T22,
            25: $lang.accountLogType.T25,
            26: $lang.accountLogType.T26
        }
    },
    {
        id: 'amount',
        title: '操作金额(元)',
        type: 'int',
        headerClass: 'text-center',
        columnClass: 'text-left',
        fastSort: false
    },
    {
        id: 'total',
        title: '账户总额(元)',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-left',
        fastSort: false
    },
    {
        id: 'available',
        title: '可用余额(元)',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-left',
        fastSort: false
    },
    {
        id: 'freeze',
        title: '冻结金额(元)',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-left',
        fastSort: false
    },
    {
        id: 'createTime',
        title: '操作时间',
        type: 'date',
        format: 'yyyy-MM-dd hh:mm:ss',
        headerClass: 'text-center',
        columnClass: 'text-left',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    },
    {
        id: 'remark',
        title: '备注',
        type: 'string',
        headerClass: 'text-left',
        columnClass: 'text-left',
        fastSort: false,
        hideType: 'md|sm|xs|lg'
    }
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'accountlog/simulate/json/list',
    exportURL: ncGlobal.adminRoot + 'accountlog/simulate/json/export',
    exportFileName: '模拟账户资金记录',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    tools: 'refresh|faseQuery|export[excel]',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {bigDecimal:["amount",'totalLeft'],int:["type"],Timestamp: ["createTime"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
grid.fastQueryParameters = new Object();
//排序
grid.sortParameter.columnId = ['asc_id'];
//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {
        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters = new Object();
            grid.fastQueryParameters['eq_delFlag'] = 1;
            grid.fastQueryParameters['lk_u.user_name_or_lk_u.mobile'] = $('#keyword').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });
    }
    //外部可调用
    return {
        bindEvent: _bindEvent,
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});